#include "SWM341.h"

void TIMR_OC_Config(TIMR_TypeDef * TIMRx, uint32_t period_ms, uint32_t high_ms);

int main(void)
{	
	SystemInit();
	
	PORT_Init(PORTB, PIN15, PORTB_PIN15_TIMR0_OUT, 0);
	TIMR_OC_Config(TIMR0, 10000, 7500);
	
	PORT_Init(PORTA, PIN13, PORTA_PIN13_BTIMR0_OUT, 0);
	TIMR_OC_Config(BTIMR0, 10000, 2500);
	
	PORT_Init(PORTA, PIN12, PORTA_PIN12_BTIMR1_OUT, 0);
	TIMR_OC_Config(BTIMR1, 10000, 5000);
	
	PORT_Init(PORTA, PIN11, PORTA_PIN11_BTIMR2_OUT, 0);
	TIMR_OC_Config(BTIMR2, 10000, 7500);
	
	PORT_Init(PORTA, PIN10, PORTA_PIN10_BTIMR3_OUT, 0);
	TIMR_OC_Config(BTIMR3, 10000, 2500);
	
	PORT_Init(PORTC, PIN12, PORTC_PIN12_BTIMR4_OUT, 0);
	TIMR_OC_Config(BTIMR4, 10000, 5000);
	
	PORT_Init(PORTC, PIN11, PORTC_PIN11_BTIMR5_OUT, 0);
	TIMR_OC_Config(BTIMR5, 10000, 7500);
	
	PORT_Init(PORTC, PIN10, PORTC_PIN10_BTIMR6_OUT, 0);
	TIMR_OC_Config(BTIMR6, 10000, 2500);
	
	PORT_Init(PORTC, PIN9,  PORTC_PIN9_BTIMR7_OUT, 0);
	TIMR_OC_Config(BTIMR7, 10000, 5000);
	
	PORT_Init(PORTC, PIN6,  PORTC_PIN6_BTIMR8_OUT, 0);
	TIMR_OC_Config(BTIMR8, 10000, 7500);
	
	PORT_Init(PORTC, PIN5,  PORTC_PIN5_BTIMR9_OUT, 0);
	TIMR_OC_Config(BTIMR9, 10000, 2500);
	
	PORT_Init(PORTC, PIN4,  PORTC_PIN4_BTIMR10_OUT, 0);
	TIMR_OC_Config(BTIMR10, 10000, 5000);
	
	PORT_Init(PORTC, PIN3,  PORTC_PIN3_BTIMR11_OUT, 0);
	TIMR_OC_Config(BTIMR11, 10000, 7500);
	
	while(1==1)
	{
	}
}


void TIMR_OC_Config(TIMR_TypeDef * TIMRx, uint32_t period_us, uint32_t high_us)
{
	TIMR_Init(TIMRx, TIMR_MODE_OC, CyclesPerUs, period_us, 0);
	
	TIMR_OC_Init(TIMRx, high_us, 0, 1);
	
	TIMR_Start(TIMRx);
}
